package com.libraries.image.tasker;

import com.libraries.helper.ImgHelper;
import com.libraries.image.listener.IImageLoadingListener;

import android.annotation.SuppressLint;
import android.graphics.Bitmap;
import android.os.AsyncTask;


/**
 *异步加载图片
 * @author wellsa
 * 
 */
@SuppressLint("NewApi")
public class ImgLoadTasker extends AsyncTask<Object, Integer, Object>{
	private IImageLoadingListener loadingListener;
	public ImgLoadTasker(IImageLoadingListener loadingListener) {
		this.loadingListener=loadingListener;
	}
	
	@Override
	protected Object doInBackground(Object... params) {
		int width=Integer.parseInt( params[0].toString());
		int height=Integer.parseInt( params[1].toString());
		String filePath=(String) params[2];
		return ImgHelper.fileToBitmap(filePath, width, height);
	}

	@Override
	protected void onPostExecute(Object result) {
		super.onPostExecute(result);
		loadingListener.onLoadingCompleted(null, (Bitmap)result, null);
	}
}
